import type {
  loginResponseModel,
  userInfoResponseModel,
} from "./model/loginModel";
import request from "@/utils/request";

// 枚举类型
enum Api {
  Login = "/admin/acl/index/login",
  GetUserInfo = "/admin/acl/index/info",
  Logout = "/admin/acl/index/logout",
}

// login是不需要token的
export const loginApi = (username: string, password: string) => {
  // 有没有给post请求进行数据类型的返回约束？loginResponseModel
  return request.post<any, loginResponseModel>(Api.Login, {
    username,
    password,
  });
};

// 获取个人信息
export const getUserInfoApi = () => {
  return request.get<any, userInfoResponseModel>(Api.GetUserInfo);
};

// 退出登录
export const logoutApi = () => {
  return request.post<any, void>(Api.Logout);
};
